//
//  DoctorTableViewCell.m
//  Doctor1.0
//
//  Created by mk on 15/9/11.
//  Copyright (c) 2015年 cocoa-mk. All rights reserved.
//

#import "DoctorTableViewCell.h"

@implementation DoctorTableViewCell

- (void)awakeFromNib
{
    // Initialization code
    for (NSLayoutConstraint *constraints in [self.desc constraints])
    {
        if (constraints.firstItem == self.desc && constraints.firstAttribute == NSLayoutAttributeWidth)
        {
            constraints.constant = appScreenWidth-20;
            break;
        }
    }

    for (NSLayoutConstraint *constraints in [self.hosp constraints])
    {
        if (constraints.firstItem == self.hosp && constraints.firstAttribute == NSLayoutAttributeWidth)
        {
            constraints.constant = appScreenWidth-96;
            break;
        }
    }

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.myImage sd_setImageWithURL:self.doc.imageUrl placeholderImage:loadDoctorImageDefaule];
    self.myImage.layer.cornerRadius = self.myImage.width / 2;
    self.myImage.clipsToBounds = YES;
    
    self.name.text = self.doc.name;
    if(self.doc.mTitle.length>0 && self.doc.aTitle.length>0)
    {
      self.mTitle.text = [NSString stringWithFormat:@"%@/%@",self.doc.mTitle,self.doc.aTitle];
    }else
    {
      self.mTitle.text = @"";
    }
    if (self.doc.desc.length>0)
     self.desc.text = [NSString stringWithFormat:@"擅长: %@",self.doc.desc];
    else
        self.desc.text = @"";
    
    self.apptButton.layer.cornerRadius = 5;
    self.apptButton.clipsToBounds = YES;
    self.apptButton.hidden = ([self.doc.isContracted isEqualToString:@"0"]);
    
    if (self.doc.hpName.length>0)
    {
      self.hosp.text = self.doc.hpName;
    }
    
}
- (IBAction)goBooking
{
    if ([self.delegate respondsToSelector:@selector(methodSignatureForSelector:)])
    {
        [self.delegate makeAnappointmentDoctorWith:self];
    }
}
@end













